{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime as dt\n",
    "from gs_quant.common import PayReceive, Currency\n",
    "from gs_quant.instrument import IRSwaption\n",
    "from gs_quant.risk import RollFwd\n",
    "from gs_quant.session import GsSession, Environment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "GsSession.use(Environment.PROD, client_id=None, client_secret=None, scopes=('run_analytics',))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "swaption = IRSwaption(PayReceive.Receive, '5y', Currency.EUR, expirationDate=dt.date(2029, 10, 8), strike='atm')\n",
    "base_price = swaption.price()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "Contexts - RollFwd"
    ]
   },
   "outputs": [],
   "source": [
    "swaption.resolve()  # fix expiry and maturity\n",
    "\n",
    "# RollFwd Scenario - Roll forward 1 month\n",
    "with RollFwd(date='1m', holiday_calendar='NYC'):\n",
    "    fwd_price = swaption.price()\n",
    "\n",
    "print('Base price:     {:,.2f}'.format(base_price))\n",
    "print('Scenario price: {:,.2f}'.format(fwd_price))\n",
    "print('Diff:           {:,.2f}'.format(fwd_price - base_price))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
